package com.ruoyi.web.controller.eamp;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.eamp.domain.vo.EampMeetingAndroomVO;
import com.ruoyi.eamp.domain.vo.EampMeetingVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.eamp.domain.EampMeeting;
import com.ruoyi.eamp.service.IEampMeetingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会议记录Controller
 * 
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/eamp/meeting")
public class EampMeetingController extends BaseController
{
    @Autowired
    private IEampMeetingService eampMeetingService;


    /**
     * 查询会议记录列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:meeting:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampMeeting eampMeeting)
    {
        startPage();
        eampMeeting.setDelFlg(1L);
        List<EampMeetingAndroomVO> list = eampMeetingService.selectEampMeetingList(eampMeeting);
        return getDataTable(list);
    }

    /**
     * 导出会议记录列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:meeting:export')")
    @Log(title = "会议记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampMeeting eampMeeting)
    {
        List<EampMeetingAndroomVO> list = eampMeetingService.selectEampMeetingList(eampMeeting);
        ExcelUtil<EampMeetingAndroomVO> util = new ExcelUtil<EampMeetingAndroomVO>(EampMeetingAndroomVO.class);
        util.exportExcel(response, list, "会议记录数据");
    }

    /**
     * 获取会议记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:meeting:query')")
    @GetMapping(value = "/{meetingId}")
    public AjaxResult getInfo(@PathVariable("meetingId") Long meetingId)
    {
        return success(eampMeetingService.selectEampMeetingByMeetingId(meetingId));
    }

    /**
     * 新增会议记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:meeting:add')")
    @Log(title = "会议记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampMeetingVO eampMeeting)
    {
        eampMeeting.setCreateTime(new Date());
        Long userId = SecurityUtils.getLoginUser().getUserId();
        System.out.println(userId);
        eampMeeting.setCreatBy(userId);
        return toAjax(eampMeetingService.insertEampMeeting(eampMeeting));
    }

    /**
     * 修改会议记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:meeting:edit')")
    @Log(title = "会议记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampMeeting eampMeeting)
    {
        return toAjax(eampMeetingService.updateEampMeeting(eampMeeting));
    }

    /**
     * 删除会议记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:meeting:remove')")
    @Log(title = "会议记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{meetingIds}")
    public AjaxResult remove(@PathVariable Long[] meetingIds)
    {
        return toAjax(eampMeetingService.deleteEampMeetingByMeetingIds(meetingIds));
    }

}
